Ext.define('ExtJs.view.system.module.SystemGrid',{
	extend:'Ext.grid.Panel',
	alias : 'widget.systemGrid',
	moduleId:0,
	initComponent:function(){
		var messageGridStore = Ext.create('ExtJs.store.system.module.SystemGridStore',{storeId:'govInfoModuleStore_'+this.moduleId});
		var govInfoModuleGrid = this;
		Ext.apply(this, {
			store:messageGridStore,
			tbar:[
				
					
					{text:'编辑',
					iconCls:'application_form',
					handler:function(){
						var storeform = govInfoModuleGrid.getSelectionModel().getSelection()[0];
					//alert(govInfoModuleGrid.getSelectionModel().getSelection()[0].get("___key_id"));
						 var w=Ext.create('Ext.window.Window',{title: ' 修改供应商',
						 width: 300,
						height: 280,
						minWidth: 200,
						minHeight: 100,
						layout: 'anchor',
						closable: true,
						//resizable:false,
						plain: true,
						items: [			        
						        Ext.create('Ext.form.Panel', {
						       layout: 'anchor',
						       				//id:'chagesupply',
					        border: false,
					        buttonAlign: 'center',
					        style: 'border-bottom:0px;',
					        url: '../servlet/supply.update',
					        items:[
					               			{
								        xtype: 'hiddenfield',
								        name: 'id',
								        value: storeform.get("___key_id")
					               			},{// 账号
					        			xtype:'textfield',
					        			inputType: 'textfiled',
					           
					            name: 'supply.name',
					            fieldLabel: '供应商名称',
					            anchor:'98%',
					            allowBlank:false,
													value:storeform.get('name'),
					            maxLength: 50
					           
						       		},{
						       	xtype:'textfield',
						       	inputType: 'textfiled',
						           
						           name:'supply.linkman',
						           fieldLabel:'联系人',
						           anchor:'98%',
						          // allowBlank:false,
													value:storeform.get('linkman'),
						           maxLength: 20
						        
						       				}
											,{
															xtype:'textfield',
										    	   inputType: 'textfiled',
										           
										           name:'supply.contact',
										           fieldLabel:'联系方式',
										           anchor:'98%',
										           value:storeform.get('contact'),
										          // allowBlank:false,
										           maxLength: 20
										        
											},{// 
												xtype:'textfield',
										    	   inputType: 'textfiled',
										
										           name:'supply.adderss',
										           fieldLabel:'地址',
										           anchor:'98%',
										           value:storeform.get('adderss'),
										          // allowBlank:false,
										           maxLength: 200
										        
											}
					        ,{// 
					        	xtype: 'textareafield',
						           
						           name:'supply.note',
						           fieldLabel:'备注',
						           anchor:'98%',
													value:storeform.get('note'),
						           //allowBlank:false,
						           //maxLength: 20
						        
										}
 									,{// 
					        			xtype: 'fieldcontainer',
						           
						           //name:'supply.status',
						           fieldLabel:'生产情况',
						           defaultType: 'checkboxfield',
										items: [
						            		    	{
						                    boxLabel  : '生产',
						                    name      : 'supply.status',
						                    inputValue: '1',
						                    checked   : true
												
               									 }
										]
						        
										}
							],
						 buttons: [{
						        text: '修改',
						        handler: function() {
						            // The getForm() method returns the Ext.form.Basic instance:
						            var form = this.up('form').getForm();
						            if (form.isValid()) {
						                // Submit the Ajax request and handle the response
						                form.submit({
						                			waitMsg : '正在保存...', 
						                    success: function(form, action) {
						                      // Ext.Msg.alert('Success', action.result.success);
						                       messageGridStore.load();
						                       w.hide();
						                    },
						                    failure: function(form, action) {
						                     //   Ext.Msg.alert('Failed', action.result.msg);
						                    }
						                });
						            }
						        }
   							 }]
						 
						        })],
				
					bbar: new Ext.Panel({
										//html: bbarHtml,
							border: false,
						bodyStyle: 'background-color:transparent;padding:3px 10px;'
					})}).show();

					}
					},
					{
						text:'添加',
						iconCls:'add',
						handler:function(){
		      var w=Ext.create('Ext.window.Window',{title: '添加供应商',
						 width: 300,
						height: 250,
						minWidth: 200,
						minHeight: 100,
						layout: 'anchor',
						closable: true,
						//resizable:false,
						plain: true,
						items: [			        
						        Ext.create('Ext.form.Panel', {
						       layout: 'anchor',
						       				//id:'supply',
					        border: false,
					        buttonAlign: 'center',
					        style: 'border-bottom:0px;',
					        url: '../servlet/supply.add',
					        items:[{// 账号
					        			xtype:'textfield',
					    						inputType: 'textfiled',
					           
					            name: 'supply.name',
					            fieldLabel: '供应商名称',
					            anchor:'98%',
					            allowBlank:false,
					            maxLength: 50
					           
						       		},{
						       	xtype:'textfield',
						       	inputType: 'textfiled',
						           
						           name:'supply.linkman',
						           fieldLabel:'联系人',
						           anchor:'98%',
						          // allowBlank:false,
						           maxLength: 20
						        
						       				}
											,{
															xtype:'textfield',
										    	   inputType: 'textfiled',
										           
										           name:'supply.contact',
										           fieldLabel:'联系方式',
										           anchor:'98%',
										          // allowBlank:false,
										           maxLength: 20
										        
											},{// 
												xtype:'textfield',
										    	   inputType: 'textfiled',
										
										           name:'supply.adderss',
										           fieldLabel:'地址',
										           anchor:'98%',
										          // allowBlank:false,
										           maxLength: 200
										        
											}
					        ,{// 
					        	xtype: 'textareafield',
						           id:'note',
						           name:'supply.note',
						           fieldLabel:'备注',
						           anchor:'98%'
						           //allowBlank:false,
						           //maxLength: 20
						        
										}
							],
						 buttons: [{
						        text: '提交',
						        handler: function() {
						            // The getForm() method returns the Ext.form.Basic instance:
						            var form = this.up('form').getForm();
						            if (form.isValid()) {
						                // Submit the Ajax request and handle the response
						                form.submit({
						                			waitMsg : '正在保存...', 
						                    success: function(form, action) {
						                       //Ext.Msg.alert('Success', action.result.success);
						                       messageGridStore.load();
						                       w.hide();
						                    },
						                    failure: function(form, action) {
						                       // Ext.Msg.alert('Failed', action.result.msg);
						                    }
						                });
						            }
						        }
   							 }]
						 
						        })],
				
					bbar: new Ext.Panel({
										//html: bbarHtml,
							border: false,
						bodyStyle: 'background-color:transparent;padding:3px 10px;'
					})}).show();
		        		}
		        	}
			],
			columns:[
				{header:'编号',dataIndex:'___key_id',hidden:true},
				{header:'供应商名称',dataIndex:'name'},
				{header:'联系人',dataIndex:'linkman'},
				{header:'联系方式',dataIndex:'contact'},
				{header:'地址',dataIndex:'adderss'},
				
				{header:'生产状态',dataIndex:'status',
					renderer: function(value,meta){
				        if (value == 1) {
				        	meta.style='color:green';
				            return '生产';
				        			}
				        meta.style='color:red';
				        return  '停产';
				        
				    }},
				{header:'描述',dataIndex:'note'}
			],
			bbar: Ext.create('Ext.PagingToolbar', {
				id:'govInfoGridPagingToolbar_'+this.moduleId,
	            store: messageGridStore,
	            displayInfo: true,
	            displayMsg: '当前 {0} - {1} / {2}',
	            emptyMsg: "没有数据"
	        })
		});
		this.callParent(arguments);
		
		
		//创建登录的panel

	}
	

});